﻿/********************************************************
 * ADO.NET 2.0 Data Provider for SQLite Version 3.X
 * Written by Robert Simpson (robert@blackcastlesoft.com)
 * 
 * Released to the public domain, use at your own risk!
 ********************************************************/
using System;
using Microsoft.VisualStudio.Data;
using Microsoft.VisualStudio.Data.AdoDotNet;
using Microsoft.Win32;

namespace EffiProz.Designer
{
    class EfzDataConnectionSupport : AdoDotNetConnectionSupport
    {
        private EfzDataViewSupport _dataViewSupport;
        private EfzDataObjectSupport _dataObjectSupport;
        private EffiProzDataObjectIdentifierResolver _dataObjectIdentifierResolver;

        public EfzDataConnectionSupport()
            : base("System.Data.EffiProz")
        {
        }

        protected override DataSourceInformation CreateDataSourceInformation()
        {
            return new EfzDataSourceInformation(Site as DataConnection);
        }

        protected override object GetServiceImpl(Type serviceType)
        {
            if (serviceType == typeof(DataViewSupport))
            {
                if (_dataViewSupport == null) _dataViewSupport = new EfzDataViewSupport();
                return _dataViewSupport;
            }

            if (serviceType == typeof(DataObjectSupport))
            {
                if (_dataObjectSupport == null) _dataObjectSupport = new EfzDataObjectSupport();
                return _dataObjectSupport;
            }


            if (serviceType == typeof(DataObjectIdentifierResolver))
            {
                if (_dataObjectIdentifierResolver == null) _dataObjectIdentifierResolver = new EffiProzDataObjectIdentifierResolver(Site);
                return _dataObjectIdentifierResolver;
            }

            if (serviceType == typeof(DataConnectionSupport))
                return this;

            return base.GetServiceImpl(serviceType);
        }
    }     
}
